package com.insigma.business.qrcode.soldier.controller;

import com.insigma.business.qrcode.common.annotation.ApiServiceType;
import com.insigma.business.qrcode.common.template.BasePagingResponse;
import com.insigma.business.qrcode.common.vo.BaseDeleteRequest;
import com.insigma.business.qrcode.common.vo.BaseResponse;
import com.insigma.business.qrcode.intell._provider.CommonPolicyBFFProvider;
import com.insigma.business.qrcode.intell.dto.CommonPolicyDTO;
import com.insigma.business.qrcode.intell.dto.CommonPolicyInsertRequest;
import com.insigma.business.qrcode.intell.dto.CommonPolicySearchRequest;
import com.insigma.business.qrcode.intell.dto.CommonPolicyUpdateRequest;
import com.insigma.business.qrcode.soldier.request.BaseGetRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(value = "老兵 码上知识库")
@RequestMapping("/web/soldierPolicy")
@RestController("soldierPolicyController")
public class SoldierPolicyController {

    @Resource
    private CommonPolicyBFFProvider commonPolicyBFFProvider;

    @ApiServiceType(value = "all.ss.commonPolicy.base.search", name = "查询数据列表", desc = "查询数据列表")
    @PostMapping("/searchCommonPolicy")
    @ApiOperation("政策列表查询")
    public BasePagingResponse<List<CommonPolicyDTO>> searchCommonPolicy(@RequestBody CommonPolicySearchRequest commonPolicySearchRequest){
        return commonPolicyBFFProvider.searchCommonPolicy(commonPolicySearchRequest);
    }


    @PostMapping("/getCommonPolicy")
    @ApiOperation("政策列表查询单条数据")
    public BaseResponse<CommonPolicyDTO> getCommonPolicy(@RequestBody BaseGetRequest baseGetRequest){
        return commonPolicyBFFProvider.getCommonPolicy(baseGetRequest);
    }


    @PostMapping("/insertCommonPolicy")
    @ApiOperation("插入政策专栏")
    public BaseResponse<String> insertCommonPolicy(@RequestBody CommonPolicyInsertRequest commonPolicyInsertRequest){
        return commonPolicyBFFProvider.insertCommonPolicy(commonPolicyInsertRequest);
    }

    @PostMapping("/updateCommonPolicy")
    @ApiOperation("更新政策专栏")
    public BaseResponse<Integer> updateCommonPolicy(@RequestBody CommonPolicyUpdateRequest commonPolicyUpdateRequest){
        return commonPolicyBFFProvider.updateCommonPolicy(commonPolicyUpdateRequest);
    }


    @PostMapping("/publishCommonPolicy")
    @ApiOperation("发布政策专栏")
    public BaseResponse<Integer> publishCommonPolicy(@RequestBody CommonPolicyUpdateRequest commonPolicyUpdateRequest){
        return commonPolicyBFFProvider.publishCommonPolicy(commonPolicyUpdateRequest);
    }


    @PostMapping("/topCommonPolicy")
    @ApiOperation("置顶政策专栏")
    public BaseResponse<Integer> topCommonPolicy(@RequestBody CommonPolicyUpdateRequest commonPolicyUpdateRequest){
        return commonPolicyBFFProvider.topCommonPolicy(commonPolicyUpdateRequest);
    }


    @PostMapping("/deleteCommonPolicy")
    @ApiOperation("删除政策专栏")
    public BaseResponse<Integer> deleteCommonPolicy(@RequestBody BaseDeleteRequest deleteRequest){
        return commonPolicyBFFProvider.deleteCommonPolicy(deleteRequest);
    }

}
